package com.yc.c112s3plyblog;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.yc.c112s3plyblog.util.DateConvertor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("com.yc.c112s3plyblog.mapper")
public class C112S3PlyBlogApplication implements WebMvcConfigurer {

    public static void main(String[] args) {
        SpringApplication.run(C112S3PlyBlogApplication.class, args);
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        // 注册自定义转换器
        registry.addConverter(new DateConvertor());
    }

    // MyBatisPlus 分页插件
    @Bean
    public MybatisPlusInterceptor mpi(){
        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();
        mpi.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return mpi;
    }
}
